package com.xiaoming.e3mall.sso.controller;

import com.xiaoming.e3mall.common.utils.E3Result;
import com.xiaoming.e3mall.pojo.TbUser;
import com.xiaoming.e3mall.sso.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 注册功能Controller
 */
@Controller
public class RegitsterController {

	@Autowired
	private RegisterService registerService;

	@RequestMapping("/page/register")
	public String showRegister() {
		return "register.jsp";
	}


	/**
	 * ajax异步校验
	 */
	@RequestMapping("/user/check/{param}/{type}")
		@ResponseBody
	public E3Result checkData(@PathVariable String param,@PathVariable Integer type){
		return registerService.checkData(param, type);
	}

	@RequestMapping(value="/user/register", method= RequestMethod.POST)
		@ResponseBody
	public E3Result register(TbUser user) {
		E3Result e3Result = registerService.register(user);
		return e3Result;
	}





}
